<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%><%-- ${fn:length(list)} --%>
<script src="jquery-1.7.2.js" type="text/javascript" charset="utf-8"></script>
<script>
	$(document).ready(function(){
		$("#time_table_delete_btn").click(function(){
			var arr = [];
			var flag=true;
			$(".delcheckboxclass").each(function() {
				var subChecked = $(this).attr("checked");
				if (subChecked=='checked'){
					arr.push($(this).val());
					flag=false;
				}
			});
			if(flag){
				alert("삭제하실 영화표를 선택하세요."); 
				return false;
			}
			if(confirm(arr.toString()+'번 예매를 취소하시겠습니까?')){
				$.ajax({
					url:"reservation.do?command=reservationDelete&list="+arr.toString(),
					dataType:"json",
					success:function(js){
						alert(arr.toString()+'번 예매 취소 되었습니다.');
						location.href="reservation.do?command=res_confirm";
					}
				});
			}
		}); // 선택삭제 button click
		$(".allcheckclass").click(function() {
			var flag = $(this).attr("checked");
			$(".delcheckboxclass").each(function() {
				var subChecked = $(this).attr("checked");
				if (subChecked != flag)
					$(this).click();
			});
		});// 모두선택 checkbox
	}); // ready
</script>
<c:choose>
<c:when test="${sessionScope.vo==null}">
<script>
	alert("로그인 하세요!");           
	location.href="mycinema.do?command=home_main";
</script>
</c:when>
<c:otherwise>
<span class="title">예매 확인/취소</span><br><hr color="#f5f5f5">
<table border="1" width="100%">
			<tr align="center" bgcolor="#f5f5f5">
				<td>영화제목</td>
				<td>영화관</td>
				<td>매수</td>
				<td>좌석번호</td>
				<td >상영일</td>
				<td>상영시간</td>
				<td>결재방식</td>
				<td>결재금액</td>
				<td>결재시간</td>
				<td><input type="checkbox" class="allcheckclass" name="Allcheck"></td>
				<td>no</td>
			</tr>
			<c:forEach items="${requestScope.map }" var="list">
		<tr align="center">
				<td>${list.MOVIE_TITLE }</td>
				<td>${list.LOC } - ${list.THEATER } - ${list.PLAY_ROOM_NO }관</td>
				<td>${list.TICKET_COUNT }매</td>
				<td>${list.SEAT_NO }</td>
				<td>${list.DAY }</td>
				<td>${list.STARTING_TIME} ~ ${list.ENDING_TIME }</td>
				<td>${list.PAYMENT }</td>
				<td>${list.PRICE} </td>
				<td>${list.BOOKING_DATE} </td>
				<td><input type="checkbox" class='delcheckboxclass' name="delcheckbox" value="${list.RES_NO }"></td>
				<td>${list.RES_NO} </td>	
		</tr>
		</c:forEach>
	</table>
	<input type="button" value="예매취소" id="time_table_delete_btn"><br>
	</c:otherwise>
</c:choose>